package com.example.controller;

import com.example.service.Calculate;
import com.example.vo.Addvo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lsjweiyi
 * @date 2021/5/8
 */
@Api(tags = "测试接口")
@RestController
public class controllerDemo {
    @Autowired
    private Calculate calculate;

    @ApiOperation(value = "获取工作信息")
    @ApiImplicitParam(name = "name",value = "访问者名字",dataType = "String",required = true)
    @GetMapping("/work")
    public String work(String name) {
        return "你好:"+name;
    }

    /**
     * @author lsjweiyi
     * @date 2021/5/8
     */
    @ApiOperation(value = "加法", notes = "只支持两位int型数字求和")
    @ApiResponses({@ApiResponse(responseCode = "200", description = "请求成功"),
            @ApiResponse(responseCode = "401", description = "认证失败"),
            @ApiResponse(responseCode = "403", description = "参数不完整"),
            @ApiResponse(responseCode = "404", description = "参数类型错误")})
    @PostMapping("/add")
    public int add(@RequestBody Addvo addvo) {
        return calculate.add(addvo);
    }
}
